import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { Files as Entity } from '@/entity/files/files.entity';

@Injectable()
export class FilestDao {

    constructor(@InjectRepository(Entity)
    private readonly repository: Repository<Entity>) { }

    /**
    * 获取一张 
    */
    findOne(id: number): Promise<Entity> {
        return this.repository.findOne(id);
    }

    /**
     * 添加
     */
    add(params: any): Promise<Entity> {
        const entity = new Entity();
        Object.assign(entity, params);
        return this.repository.save(entity);
    }

}
